package com.spring.dao;

import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

/**
 * @author 67030
 */
public class UserDynaSqlProvider {
    public String isExist(String userCode){
        return new SQL(){{
            SELECT("*");
            FROM("sys_user");
            WHERE("usercode=#{userCode}");
        }}.toString();
    }
    public String login(Map<String,Object> params){

        return new SQL() {
            {
                SELECT("*");
                FROM("sys_user");
                if(params.get("psw")!=null){
                    WHERE("psw= #{psw}");
                }
                if(params.get("userCode")!=null){
                     WHERE("userCode= #{userCode}");
                }


            }
        }.toString();
    }

    public String register(Map<String,Object> params){
        return new SQL(){{
            INSERT_INTO("sys_user");
            VALUES("usercode","#{userCode}");
            VALUES("psw","#{psw}");
            VALUES("name","#{name}");
        }}.toString();
    }
    public String selectUsers(String name){
        return new SQL(){{
            SELECT("*");
            FROM("sys_user");
            WHERE("name=#{name}");
        }}.toString();
    }

    public String updateUserInfo(Map<String,Object> params){
        return new SQL(){{

        }}.toString();
    }
}
